<?php
class PartnerTypeModel
{
	static private $_tableName = 'partner_type'; 
	
	static public function getTableName()
	{
		return self::$_tableName;
	}
	
	static public function getAll()
	{
		$result = array();
		$sql = 'SELECT * FROM '.self::getTableName();
		$result = DB::fetchAll($sql);
		return $result;
	}
	
	static public function existName($name)
	{
		$sql = 'SELECT id FROM '.self::getTableName().' WHERE name=:name';
		$data = array('name' => $name);
		$result = DB::fetch($sql, $data);
		return $result;
	}
	
	static public function insert($params)
	{
		$sql = 'INSERT INTO '.self::getTableName() .' (name) VALUES (:name)';
		$data = array('name' => $params['name']);
		$result = DB::insert($sql, $data);
		return $result;
	}
	
	static public function update($params)
	{
		$sql = 'UPDATE '.self::getTableName() .' SET name = :name WHERE id = :id';
		$data = array('name' => $params['name'], 'id'=>$params['id']);
		$result = DB::execute($sql, $data);
		return $result;
	}
	
	static public function delete($id)
	{
		$sql = 'DELETE FROM '.self::getTableName() .' WHERE id = :id';
		$data = array('id' => $id);
		$result = DB::execute($sql, $data);
		return $result;
	}
	
	
}